package cn.edu.xcu.ckl.fragment;

import android.content.Context;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;

import cn.edu.xcu.ckl.R;
import cn.edu.xcu.ckl.base.BaseFragment;
import cn.edu.xcu.ckl.utils.AcListener;


public class HomeFragment extends BaseFragment implements View.OnClickListener {
    private RelativeLayout rel1,rel2,rel3;
    private RadioButton shop_type1,shop_type2,shop_type3,shop_type4;
    private AcListener mAcListener;

    @Override
    public void onAttach(@NonNull Context context) {
        super.onAttach(context);
        mAcListener = (AcListener) context;
    }



    @Override
    protected int getContentView() {
        return R.layout.fragment_home;
    }

    @Override
    protected void initView() {

        //初始化控件
        rel1 =rootView.findViewById(R.id.rel1);
        rel2 =rootView.findViewById(R.id.rel2);
        rel3 =rootView.findViewById(R.id.rel3);
        //
        shop_type1=rootView.findViewById(R.id.shop_type1);
        shop_type1.setOnClickListener(this);
        shop_type2=rootView.findViewById(R.id.shop_type2);
        shop_type2.setOnClickListener(this);
        shop_type3=rootView.findViewById(R.id.shop_type3);
        shop_type3.setOnClickListener(this);
        shop_type4=rootView.findViewById(R.id.shop_type4);
        shop_type4.setOnClickListener(this);

    }

    @Override
    protected void setListener() {
        rel1.setOnClickListener(this);
        rel2.setOnClickListener(this);
        rel3.setOnClickListener(this);

    }

    @Override
    protected void initData() {

    }

    @Override
    public void onClick(View v) {
        if (v.getId() ==R.id.rel1 || v.getId()==R.id.rel2 || v.getId()==R.id.rel3){
               if (null!=mAcListener){
                   mAcListener.currentIndex(1);
               }
        }else if (v.getId()==R.id.shop_type1 || v.getId() ==R.id.shop_type2 || v.getId() ==R.id.shop_type3 || v.getId()==R.id.shop_type4){
            if (null!=mAcListener){
                mAcListener.currentIndex(1);
            }
        }
    }
}